package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.SysCalendar;
import com.ruoyi.system.mapper.SysCalendarMapper;
import com.ruoyi.system.service.SysCalendarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xmh
 * @version 1.0
 * @description: TODO
 * @date 2024/12/6 21:47
 */
@Service
public class SysCalendarServiceImpl implements SysCalendarService {

    @Resource
    private SysCalendarMapper sysCalendarMapper;

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param id 日程id
     * @description: TODO 查询日程详情
     */
    @Override
    public SysCalendar selectSysCalendarById(String id) {
        return sysCalendarMapper.selectSysCalendarById(id);
    }

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param sysCalendar 日程
     * @description: TODO 查询日程列表
     */
    @Override
    public List<SysCalendar> selectSysCalendarList(SysCalendar sysCalendar) {
        return sysCalendarMapper.selectSysCalendarList(sysCalendar);
    }

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param sysCalendar 日程
     * @description: TODO 新增日程
     */
    @Override
    public int insertSysCalendar(SysCalendar sysCalendar) {
        sysCalendar.setId(IdUtils.fastSimpleUUID());
        sysCalendar.setCreateBy(SecurityUtils.getUserId()+"");
        sysCalendar.setCreateTime(DateUtils.getNowDate());
        sysCalendar.setDeptId(SecurityUtils.getDeptId());
        return sysCalendarMapper.insertSysCalendar(sysCalendar);
    }

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param sysCalendar 日程
     * @description: TODO 修改日程
     */
    @Override
    public int updateSysCalendar(SysCalendar sysCalendar) {
        sysCalendar.setUpdateBy(SecurityUtils.getUserId()+"");
        sysCalendar.setUpdateTime(DateUtils.getNowDate());
        return sysCalendarMapper.updateSysCalendar(sysCalendar);
    }

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param id 日程id
     * @description: TODO 删除日程
     */
    @Override
    public int deleteSysCalendarById(String id) {
        return sysCalendarMapper.deleteSysCalendarById(id);
    }

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param ids – 需要删除的数据主键集合
     * @description: TODO 批量删除日程
     */
    @Override
    public int deleteSysCalendarByIds(String[] ids) {
        return sysCalendarMapper.deleteSysCalendarByIds(ids);
    }

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param yearMonth – 年月 2024-12
     * @description: TODO 根据年月查询休息日的天数
     */
    @Override
    public int findRestDayByDate(String yearMonth) {
        return sysCalendarMapper.findRestDayByDate(yearMonth);
    }

    /**
     * @author xmh
     * @date 2024/12/6 21:49
     * @param yearMonthDay - 年月日 2024-12-06
     * @description: TODO 根据年月日查询某天是否休息
     */
    @Override
    public int findDayIsRest(String yearMonthDay) {
        return sysCalendarMapper.findDayIsRest(yearMonthDay);
    }
}
